<?php
//////////////////////////////////////
// Class Registration System  		//
// CPSC 462				      		//
// Main Page                  		//
// Trent Robbins & Richard Heywood  //
//////////////////////////////////////

date_default_timezone_set('America/New_York');
include('Website.class.php');
$css = '';
$js = '';
$js .= '<script type="text/javascript" src="./js/jquery/jquery.form.js"></script>
		<script type="text/javascript" src="./js/jquery/jquery.validate.min.js"></script>
		<script type="text/javascript" src="./js/jquery/jquery.validate.additional.js"></script>
		<script type="text/javascript" src="./js/jquery/jquery-ui-1.8rc1.custom.min.js"></script>';
$js .= "<script type='text/javascript'>".file_get_contents('./js/main.js')."</script>";
$body = '';
$studId = $_GET['studId'];
$mainPage = new Website();
$mainPage->dbConnect();

list($fName,$lName,$major,$year,$enrolled,$hoursLimit) = $mainPage->getStudentInfo($studId);

$body .= "<table class='studInfo'>
			<tr>
				<td class='pic'>
					<div id='studImage'>";
					
if (file_exists("./pics/students/{$studId}.jpg")){
	$body .= "			<img src='./pics/students/{$studId}.jpg' alt='Student Picture'/><br />";
}
elseif(file_exists("./pics/students/{$studId}.gif")){
	$body .= "			<img src='./pics/students/{$studId}.gif' alt='Student Picture'/><br />";
}
else{
	$body .= 			"<img src='./pics/students/default.jpg' alt='Student Picture'/><br />";
}					
$body .=			"</div>
				</td>
				<td class='studInfo'>
					First Name:<br />
				
					Last Name:<br />
				
					Major:<br />
				
					Academic Standing:<br />
				
					Enrollment Status:<br />
					
					Hours Limit: <br />
				</td>
				<td class='studInfo'>
					$fName <br />
					
					$lName <br />
					 
					$major <br />
					
					".$mainPage->getStandingByYear($year)."<br />
					
					".$mainPage->processEnrollment($enrolled)."<br />
					
					$hoursLimit <br />
				</td>
			</tr>
		 </table>";
$body .= "<div id='picUpload'>
			<form id='picUploadForm' action='fileUpload.php' method='post' autocomplete='off' enctype='multipart/form-data'>
				<label for='file'>Filename:</label>
				<input type='file' name='file' id='picFile' />
				<input type='hidden' name='hid' id='Hid_studId' value='$studId'/>
				<input type='submit' name='upload' value='Upload' id='uploadButton'/>
			</form>
		</div><br />";
$hours = $mainPage->getRegisteredHours($studId);
$body .= "Schedule: $hours Hours <br /><br />";
			if($hours>0){
				$body .= $mainPage->getStudentCurrentCourses($studId);
			}
			else{
				$body .= "Not Yet Registered for Any Courses";
			}
			$body .= '<br /><br />';
$reqHours = $mainPage->getRequestedHours($studId);
$body .= "Requested Hours: $reqHours<br /><br />";
			if($reqHours>0){
				$body .= $mainPage->getRequestedCourses($studId);
				$body .= "<br /><br />";
			}
			else{
				$body .="<br />";
			}
$body .= "<a href='./courseDirectory.php?studId=$studId'><input type='button' value='Search for Classes'></a><br /><br />
		  <a href='./index.php'><input type='button' value='Logout'></a>
		  <br /><br />";
$body .= '</div>';

$mainPage->createPage('Class Registration',$css,$js,$body);

$mainPage->dbCloseConnect();
?>
